/*
* Copyright (C) 2019 ~ 2021 Uniontech Software Technology Co.,Ltd.
*
* Author:     yanghongwei <yanghongwei@uniontech.com>
*
* Maintainer: yanghongwei <yanghongwei@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef NOTIFYMANAGE_H
#define NOTIFYMANAGE_H

#include "common.h"

#include <QObject>

class Fanotify;
class Inotify;
class NotifyManage : public QObject
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "com.scorpio.test.addUDiskDir")
public:
    explicit NotifyManage(QObject *parent = nullptr);

public slots:
    void addUDiskDir(const QString &path);
    void addRootDir(const QString &path);
    void startWatch();
private:
    void initDir(const QString &path);
    void clearOldData(QList<OperationNode> &nodes, const QDateTime &beforeDate);
    QPair<QString, QString> copyUDisk(const QString & path1, const QString & path2);

signals:

private slots:
    void operationHappen(OperationNode node);
    void processNode();

private:
    Fanotify *m_fanotify;
    Inotify *m_inotify;

    QString m_currentOperator;
    QList<OperationNode> m_inotifyAccessList;
    QList<OperationNode> m_inotifyCreateList;

    QStringList m_rootDirs;
    QStringList m_uDiskDirs;
};

#endif // NOTIFYMANAGE_H
